package com.ssi.mrms.dao.mapping;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.ResultSetExtractor;
import org.springframework.jdbc.core.RowMapper;

import com.ssi.mrms.model.ManageProjectModel;
/**
 * 
 * @author Praijittra K.
 * @date 7 Mar 2014
 *
 */
public class ManageProjectMapping implements RowMapper<ManageProjectModel>{

	public ManageProjectModel mapRow(ResultSet rs, int line) throws SQLException {
		ResultSetExtractor<ManageProjectModel> extractor = new ResultSetExtractor<ManageProjectModel>() {
			public ManageProjectModel extractData(ResultSet rs) throws SQLException, DataAccessException {
				ManageProjectModel model = new ManageProjectModel(
						rs.getInt("id"), 
						rs.getInt("project_id"),
						rs.getInt("ACC_SITE_Acc_id"),
						rs.getString("project_name"),
						rs.getString("project_nickname")						
						);
				model.setCreateUser(rs.getString("create_by"));
				model.setCreateDate(rs.getDate("create_date"));
				model.setUpdateUser(rs.getString("update_by"));
				model.setUpdateDate(rs.getDate("update_date"));
				return model;
			}
		};
		return extractor.extractData(rs);
	}

}
